

package ru.samgtu.wst.ui.swing;

import ru.samgtu.wst.model.Preferences;

import java.util.Date;
import javax.swing.table.DefaultTableCellRenderer;

import java.text.SimpleDateFormat;


public class DateRenderer extends DefaultTableCellRenderer {

	private SimpleDateFormat _sdf;

	public DateRenderer() {
		String format = Preferences.getPreference("WST.DateFormat",
				"yyyy/MM/dd HH:mm:ss");
		_sdf = new SimpleDateFormat(format);
	}

	@Override
	public void setValue(Object value) {
		if ((value != null) && (value instanceof Date)) {
			Date date = (Date) value;
			// value = DateUtil.rfc822Format(date);
			value = _sdf.format(date);
		}
		super.setValue(value);
	}

}
